/***
*	统计.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
*	Created by Lenovo no  2019/9/23 下午 4:55:28
*	in machine : LAPTOP-EVRVG9A2
****/
#include <stdio.h>
#include <string.h>
int main(int argc,char* atgv[])
{
	float number[26] = { 0 };
	FILE* fp;
	int total = 0;
	int i;
	char c;
	//fp = fopen("Text.txt", "r");
    if(strcmp(argv[1], "-c") == 0){ 
    fp = fopen(argv[2], "r")}

	if (fp != NULL)
		while (!feof(fp)) {
			c = fgetc(fp);  //从文档中读取字母放置c中
			if (c >= 'A' && c <= 'Z') {
				number[c - 'A']++;
				total++;
			}
			else if (c >= 'a' && c <= 'z') {
				number[c - 'a']++;
				total++;
			}
		}
	else
		printf("Fail to open file!\n");
	fclose(fp);  //关闭文档
	for (i = 0; i < 26; i++) {
		printf("%c,%c\t:\t%0.6f \n", 'a' + i, 'A' + i, number[i] / total);
		//打印出字母及频率
	}
	printf("字母总数为：%d", total);  //统计字母总数
return 0;
}